package interfaces.spawnMenu.costumize.weapons;

import java.util.HashMap;
import java.util.List;

import logic.common.player.Player;
import logic.nodes.nodeSettings.Settings;
import logic.weapons.WeaponProperties;
import logic.weapons.projectileWeapons.ProjectileProperties;
import logic.weapons.projectileWeapons.heatSeeker.HeatSeekerProperties;
import fileHandling.language.Lang;
import fileHandling.language.properties.NodeProps;
import fileHandling.language.properties.WeaponProps;
import interfaces.PropertyWidget;
import interfaces.spawnMenu.costumize.InfoContent;

public class WeaponInfoContent extends InfoContent {
	
	protected PropertyWidget projectilesWidget, agilityWidget;
	
	public WeaponInfoContent(int width, int height, int x, int y, WeaponProperties weaponProps, 
			Settings maxValues, HashMap<Lang, String[]> keys, List<Lang> keyOrderList, Player player) {
		super(width, height, x, y, keys, weaponProps, maxValues, null, true, 5, keyOrderList, player);
	}
	
	public void setProperties(WeaponProperties props) {
		settings = props;
		if(props instanceof ProjectileProperties) {
			if(projectilesWidget == null) {
				Lang descr = WeaponProps.MaxProjectiles;
				String[] keys = new String[] { WeaponProps.MaxProjectiles.toString() };
				projectilesWidget = addWidget(descr, keys);
			} else if(getContent().contains(projectilesWidget)) projectilesWidget.setProperties(props);
			else {
				addWidget(projectilesWidget);
				allWidgets.add(projectilesWidget);
			}
			if(props instanceof HeatSeekerProperties) {
				if(agilityWidget == null) {
					Lang descr = NodeProps.Agility;
					String[] keys = new String[] { NodeProps.Agility.toString() };
					agilityWidget = addWidget(descr, keys);
				} else if(getContent().contains(agilityWidget)) agilityWidget.setProperties(props);
				else {
					addWidget(agilityWidget);
					allWidgets.add(agilityWidget);
				}
			} else {
				removeWidget(agilityWidget);
				allWidgets.remove(agilityWidget);
			}
		} else {
			removeWidget(projectilesWidget);
			allWidgets.remove(projectilesWidget);
			removeWidget(agilityWidget);
			allWidgets.remove(agilityWidget);
		}
		super.setProperties(props);
	}
}